# 配置文件
import os


class Config:
    # 配置MySQL参数
    MYSQl_DIALECT = "mysql"  # 数据库方言
    MYSQl_DRIVER = "pymysql"  # 数据库驱动
    MYSQl_NAME = "root"  # 用户名
    MYSQl_PWD = "123456"  # 密码
    MYSQl_HOST = "localhost"  # 主机地址
    MYSQl_PORT = "3306"  # 端口
    MYSQl_DB = "flask_shop"  # 连哪个数据库
    MYSQl_CHARSET = "utf8m64"  # 编码

    SQLALCHEMY_DATABASE_URI = f"{MYSQl_DIALECT}+{MYSQl_DRIVER}://{MYSQl_NAME}:{MYSQl_PWD}@{MYSQl_HOST}:{MYSQl_PORT}/{MYSQl_DB}?{MYSQl_CHARSET}"
    SQLALCHEMY_TRACK_MODIFICATIONS = True  # 动态追踪修改设置，如未设置只会提示警告

    SECRET_KEY = os.urandom(16)  # 秘钥，加盐
    DEBUG = True

    ALLOWED_IMGS = (["bmp", "png", "jpg", "jpeg", "gif"])
    BASE_DIR = os.path.dirname(os.path.abspath(__file__))
    SERVER_IMG_UPLOADS = os.path.join(BASE_DIR, "flask_shop", "static", "img")


class DevelopmentConfig(Config):  # 开发模式
    DEBUG = True


class ProductionConfig(Config):  # 生产模式
    pass


config_map = {
    "develop": DevelopmentConfig,
    "product": ProductionConfig
}
